package com.lx.dao;

import com.lx.pojo.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

//使用注解
public interface CommentUserMapper {

    @Select("select * from `user`")
    List<User> getAllUsers();

    //sql语句中的参数要和@Param中的值一致
    @Select("select * from `user` where id = #{userId}")
    User getUserById(@Param("userId") int id);

    //当参数为实体类时，sql中赋值参数应当与实体类中的字段一致
    @Insert("insert into `user` values (#{id},#{name},#{password})")
    int addUser(User user);

    @Update("update `user` set `name`=#{name},pwd=#{password} where id = #{id}")
    int updateUser(User user);

    @Delete("delete from `user` where id = #{id}")
    int deleteUser(int id);

}
